//
// Created by liushuai on 2021/2/17.
//

#include "countSegments.h"
int countSegments(string s){
    int res = 0;
    int start = 0;
    int end = 0;
    int size = s.size();
    if(size==0)
        return 0;
    while (start<size&&end<size){
        if(s[start]!=' '&&s[end]!=' '){
            while (s[end]!=' '&&end<size)
                end++;
            res+=1;
            start = end+1;
            end = start;
        } else{
            start++;
            end++;
        }
    }
    return res;
}